import openpyxl
import pymysql


workbook = openpyxl.load_workbook('5.baidu-员工的人员信息.xlsx')
worksheet = workbook['Sheet1']

# db = 新增数据.InsertUtils('127.0.0.1', 'root', '123456', 'test')
# sql = "insert into user_info values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

# workbook = openpyxl.load_workbook('user.xlsx')
# worksheet = workbook['user']

db = pymysql.connect(
    host='localhost',
    user='root',
    password='123456',
    database='test',
    port=3306,
    charset='utf8'
)
cursor = db.cursor()

# sql = "insert into user_table values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"


for i in worksheet.iter_rows(min_row=2, max_row=2001, min_col=1, max_col=14):
    data = []
    data1 = ()
    for j in i:
        data.append(j.value)
    for i in data:
        data1 = (data[0],data[1],data[2],data[3],data[4],data[5],data[6],
                 data[7],data[8],data[9],data[10],data[11],data[12],data[13])
    # sql = "insert into user_table values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    sql = "insert into user_info values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

    cursor.execute(sql,data1)
    db.commit()

cursor.close()
db.close()




